﻿#ifndef HTTPSERVICE_H
#define HTTPSERVICE_H

#include <QObject>
#include <httplistener.h>
#include <httpsessionstore.h>
#include <filelogger.h>
#include <requestmapper.h>


using namespace stefanfrings;

class HttpService : public QObject
{
    Q_OBJECT
public:
    /**
    * 获取单例实例
    * @return 返回单例实例
    */
    static HttpService* getInstance();
    /**
    * 删除单例实例
    */
    static void deleteInstance();

    void installController(QString path, HttpRequestHandler *httpRequestHandler);

    HttpSessionStore *getHttpSessionStore() const;

private:
    void open();
    void close();
private:
    explicit HttpService(QObject *parent = nullptr);
    ~HttpService();

    static HttpService* instance;
    static QMutex mutex;

    HttpSessionStore *httpSessionStore;
    RequestMapper* requestMapper;
    HttpListener *httpListener;
    Logger *logger;//日志
};

#endif // HTTPSERVICE_H
